1 <?php
2     
3     session_start();
4     require
"includes/functions.php";
5     require
"includes/db.php";
6     
if(!isset($_SESSION['user'])) {
7         header(
"location: logout.php");
8     }
9     
10     $table_no =
0;
11     $get_table_no = $db->query(
"SELECT * FROM Globals");
12     
if($get_table_no->num_rows) {
13         $row_no = $get_table_no->fetch_assoc();
14         $table_no = htmlentities($row_no[
'global_amt']);
15     }
16     
17     
18     $result =
"";
19     $pagenum =
"";
20     $per_page =
20;
21         
22         $count = $db->query(
"SELECT * FROM reservation");
23         
24         $pages = ceil((mysqli_num_rows($count)) / $per_page);
25         
26         
if(isset($_GET['page'])) {
27             
28             $page = $_GET[
'page'];
29             
30         }
else{
31             
32             $page =
1;
33             
34         }
35                         
36         $start = ($page -
1) * $per_page;
37         
38         $reserve = $db->query(
"SELECT * FROM reservation LIMIT $start, $per_page");
39         
40         
if($reserve->num_rows) {
41             
42             $result =
"<table class='table table-hover'>
43                         <thead>
44                             <th>S/N</th>
45                             <th>Bàn số</th>
46                             <th>Email</th>
47                             <th>Di động</th>
48                             <th>Ngày đặt</th>
49                             <th>Giờ đặt</th>
50                             <th>Gợi ý</th>
51                             <th>Hoạt động</th>
52                         </thead>
53                         <tbody>"
;
54             
55             $x =
1;
56             
57             
while($row = $reserve->fetch_assoc()) {
58                 
59                 $reserve_id = $row[
'reserve_id'];
60                 $no_of_guest = $row[
'no_of_guest'];
61                 $email = $row[
'email'];
62                 $phone = $row[
'phone'];
63                 $date_res = $row[
'date_res'];
64                 $time = $row[
'time'];
65                 $suggestions = $row[
'suggestions'];
66                 
67                 
68                 $result .=
"<tr>
69                                 <td>$x</td>
70                                 <td>
71                                 <div style='text-align: center;'>
72                                     <img style='width: 70px;' src='
1887799-200.png'/>
73                                     <p>Bàn $no_of_guest</p>
74                                 </div>
75                                 </td>
76                                 <td>$email</td>
77                                 <td>$phone</td>
78                                 <td>$date_res</td>
79                                 <td>$time</td>
80                                 <td>$suggestions</td>
81                                 <td><a href='reservations.php?delete="
.$reserve_id."' onclick='return check();'><i class='pe-7s-close-circle'></i></a></td>
82                             </tr>"
;
83                                                                 
84                                     
85                 $x++;
86             }
87             
88             $result .=
"</tbody>
89                         </table>"
;
90             
91         }
else{
92             
93             $result =
"<p style='color:red; padding: 10px; background: #ffeeee;'>No Table reservations available yet</p>";
94             
95         }
96     
97     
if(isset($_GET['delete'])) {
98         
99         $delete = preg_replace(
"#[^0-9]#", "", $_GET['delete']);
100         
101         
if($delete != "") {
102             
103             $sql = $db->query(
"DELETE FROM reservation WHERE reserve_id='".$delete."'");
104         
105             
if($sql) {
106                 
107                 echo
"<script>alert('Successfully deleted')</script>";
108                 
109             }
else{
110                 
111                 echo
"<script>alert('Operation Unsuccessful. Please try again')</script>";
112                 
113             }
114             
115         }
116         
117         
118     }
119     
120     
if(isset($_POST['submit'])) {
121             
122         $notable = htmlentities($_POST[
'number'], ENT_QUOTES, 'UTF-8');
123         
124         
if($notable == "") {
125             echo
"<script>alert('No form data sent')</script>";
126         }
else{
127             $update = $db->query(
"UPDATE Globals SET global_amt='$notable'");
128             
129             
if($update) {
130                 echo
"<script>alert('Successfully Updated')</script>";
131                 
//header("reservations.php");
132             }
else{
133                 echo
"<script>alert('Problem encountered. Please try again')</script>";
134             }
135         }
136             
137     }
138     
139 ?>
140
141 <!doctype html>
142 <html lang=
"en">
143 <head>
144     <meta charset=
"utf-8" />
145     <link rel=
"icon" type="image/png" href="assets/img/favicon.ico">
146     <meta http-equiv=
"X-UA-Compatible" content="IE=edge,chrome=1" />
147
148     <title>Milk Tea Hương Vị Thơm - Chuẩn Vị Ngon</title>
149
150     <meta content=
'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
151     <meta name=
"viewport" content="width=device-width" />
152
153
154     <!-- Bootstrap core CSS -->
155     <link href=
"assets/css/bootstrap.min.css" rel="stylesheet" />
156
157     <!-- Animation library
for notifications -->
158     <link href=
"assets/css/animate.min.css" rel="stylesheet"/>
159
160     <!-- Light Bootstrap Table core CSS -->
161     <link href=
"assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
162
163
164     <!-- CSS
for Demo Purpose, don't include it in your project -->
165     <link href=
"assets/css/demo.css" rel="stylesheet" />
166
167
168     <!-- Fonts and icons -->
169     <link href=
"assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
170     
171     
172     <link href=
"assets/css/style.css" rel="stylesheet" />
173     
174     <script>
175     
176         function check() {
177             
178             
return confirm("Are you sure you want to delete this record");
179             
180         }
181         
182     </script>
183     
184 </head>
185 <body>
186
187 <div
class="wrapper">
188     <div
class="sidebar" data-color="#000" data-image="assets/img/sidebar-5.jpg">
189
190     <!-- you can change the color of the sidebar
using: data-color="blue | azure | green | orange | red | purple" -->
191
192
193         <?php require
"includes/side_wrapper.php"; ?>
194
195     <div
class="main-panel">
196         <nav
class="navbar navbar-default navbar-fixed" style="background: #FF5722;">
197             <div
class="container-fluid">
198                 <div
class="navbar-header">
199                     <button type=
"button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
200                         <span
class="sr-only">Toggle navigation</span>
201                         <span
class="icon-bar" style="background: #fff;"></span>
202                         <span
class="icon-bar" style="background: #fff;"></span>
203                         <span
class="icon-bar" style="background: #fff;"></span>
204                     </button>
205                     <a
class="navbar-brand" href="#" style="color: #fff;">Danh sách đặt bàn</a>
206                 </div>
207                 <div
class="collapse navbar-collapse">
208
209                     <ul
class="nav navbar-nav navbar-right">
210                         <li>
211                             <a href=
"logout.php" style="color: #fff;">
212                                 Thoát
213                             </a>
214                         </li>
215                     </ul>
216                 </div>
217             </div>
218         </nav>
219
220
221         <div
class="content">
222             <div
class="container-fluid">
223                 <div
class="row">
224                     <div
class="col-md-12">
225                         <div
class="card">
226                             <div
class="header">
227                                 <h4
class="title">Thiết lập bàn</h4>
228                             </div>
229                             <div
class="content table-responsive table-full-width">
230                                 
231                                 <form method=
"post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
232                                     <div
class="row">
233                                         <div
class="container">
234                                             <div
class="col-md-4">
235                                                 <input type=
"number" autofocus name="number" value="<?php echo $table_no; ?>" class="form-control" placeholder="Nhập số bàn: E.g 5" required />
236                                             </div>
237                                             <div
class="col-md-4">
238                                                 <input type=
"submit" name="submit" style="background: #FF5722; border: 1px solid #FF5722" value="Update" class="btn btn-info btn-fill" />
239                                             </div>
240                                         </div>
241                                     </div>
242                                     
243                                 </form>
244
245                             </div>
246                         </div>
247                     </div>
248
249                 </div>
250             </div>
251             
252             <div
class="container-fluid">
253                 <div
class="row">
254                     <div
class="col-md-12">
255                         <div
class="card">
256                             <div
class="header">
257                                 <h4
class="title">Danh sách đặt bàn</h4>
258                             </div>
259                             <div
class="content table-responsive table-full-width">
260                                 
261                                 <?php echo $result; ?>
262
263                             </div>
264                         </div>
265                     </div>
266
267                 </div>
268             </div>
269             
270         </div>
271
272         <footer
class="footer">
273             <div
class="container-fluid">
274                 
275                 <p
class="copyright pull-right">
276                     &copy;
2016 <a href="index.php" style="color: #FF5722;">Milk Tea Hương Vị Thơm - Chuẩn Vị Ngon</a>
277                 </p>
278             </div>
279         </footer>
280
281     </div>
282 </div>
283
284
285 </body>
286
287     <!-- Core JS Files -->
288     <script src=
"assets/js/jquery-1.10.2.js" type="text/javascript"></script>
289     <script src=
"assets/js/bootstrap.min.js" type="text/javascript"></script>
290
291     <!-- Checkbox, Radio & Switch Plugins -->
292     <script src=
"assets/js/bootstrap-checkbox-radio-switch.js"></script>
293
294     <!-- Charts Plugin -->
295     <script src=
"assets/js/chartist.min.js"></script>
296
297     <!-- Notifications Plugin -->
298     <script src=
"assets/js/bootstrap-notify.js"></script>
299
300     <!-- Google Maps Plugin -->
301     
302     <!-- Light Bootstrap Table Core javascript and methods
for Demo purpose -->
303     <script src=
"assets/js/light-bootstrap-dashboard.js"></script>
304
305     <!-- Light Bootstrap Table DEMO methods, don
't include it in your project! -->
306     <script src=
"assets/js/demo.js"></script>
307     
308     
309
310 </html>


Gõ tìm kiếm nhanh...